<HTML>

<HEAD>
   <TITLE>appendix A -- Quiz Answers</TITLE>
   <META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>appendix A</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>Quiz Answers</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
<H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A>
</FONT></FONT></H3>


<UL>
<LI><A HREF="#Day1" >Day 1</A>
<LI><A HREF="#Day2" >Day 2</A>
<LI><A HREF="#Day3" >Day 3</A>
<LI><A HREF="#Day4" >Day 4</A>
<LI><A HREF="#Day5" >Day 5</A>
<LI><A HREF="#Day6" >Day 6</A>
<LI><A HREF="#Day7" >Day 7</A>
<LI><A HREF="#Day8" >Day 8</A>
<LI><A HREF="#Day9" >Day 9</A>
<LI><A HREF="#Day10" >Day 10</A>
<LI><A HREF="#Day11" >Day 11</A>
<LI><A HREF="#Day12" >Day 12</A>
<LI><A HREF="#Day13" >Day 13</A>
<LI><A HREF="#Day14" >Day 14</A>
<LI><A HREF="#Day15" >Day 15</A>
<LI><A HREF="#Day16" >Day 16</A>
<LI><A HREF="#Day17" >Day 17</A>
<LI><A HREF="#Day18" >Day 18</A>
<LI><A HREF="#Day19" >Day 19</A>
<LI><A HREF="#Day20" >Day 20</A>
<LI><A HREF="#Day21" >Day 21</A>
</UL>
<HR>
<P>
This appendix contains answers to the quiz questions presented
at the end of each lesson. Please refer to these answers to check
your own answers to the questions. I would tell you to feel free
to grade yourself, but this is supposed to be fun!
<H2><A NAME="Day1"><B><FONT SIZE=5 COLOR=#FF0000>Day 1</FONT></B></A>
</H2>
<OL>
<LI>This is just too easy-it's Visual Basic! Just kidding, the
correct answer is Java.
<LI>The opportunity to allow people from all over to share in
an interactive gaming experience.
</OL>
<H2><A NAME="Day2"><B><FONT SIZE=5 COLOR=#FF0000>Day 2</FONT></B></A>
</H2>
<OL>
<LI>The keyboard and mouse.
<LI>It only supports the ULAW sound format and doesn't provide
any means to manipulate sound data.
<LI>A piece of multimedia data used by a game, such as an image
or a sound.
<LI>To tell the story of a game graphically, scene by scene, by
using rough sketches of each scene.
</OL>
<H2><A NAME="Day3"><B><FONT SIZE=5 COLOR=#FF0000>Day 3</FONT></B></A>
</H2>
<OL>
<LI>Software bundles of data and the methods that act on that
data.
<LI>The process of packaging an object's data together with its
methods.
<LI>Because it allows parts of a program to change without subsequently
affecting other parts, resulting in far better control over code
maintenance.
<LI>Performance.
</OL>
<H2><A NAME="Day4"><B><FONT SIZE=5 COLOR=#FF0000>Day 4</FONT></B></A>
</H2>
<OL>
<LI>CompuServe created the GIF image format in 1987 as a means
to establish platform-independence in graphical images.
<LI>The technique of storing an image so that it can be drawn
incrementally as it is being loaded. Interlacing is used frequently
in Web page images.
<LI>The process of reducing the colors in an image to a lesser
number of colors, while still maintaining a similar look.
<LI>A graphical object with multiple animation frames, which are
also known as phases of the object.
<LI>Decide how much you can afford to pay for the artwork, find
out if the artist has experience with computer graphics, and develop
a good idea of what specific artwork you want the artist to create.
</OL>
<H2><A NAME="Day5"><B><FONT SIZE=5 COLOR=#FF0000>Day 5</FONT></B></A>
</H2>
<OL>
<LI>Red, green, blue, and alpha.
<LI>An abstract representation of a drawing surface.
<LI>The <TT><FONT FACE="Courier">FontMetrics</FONT></TT> class.
<LI>To provide a means of monitoring the load progress of images
and (eventually) other media objects.
</OL>
<H2><A NAME="Day6"><B><FONT SIZE=5 COLOR=#FF0000>Day 6</FONT></B></A>
</H2>
<OL>
<LI>The illusion of movement is created by displaying images in
rapid succession with small changes in content between each.
<LI>Frame-based animation and cast-based (sprite) animation.
<LI>Transparency is a technique used to draw only the relevant
part of a rectangular image. This is extremely useful in sprite
animation, where many objects have irregular shapes yet are modeled
as rectangular images.
<LI>Flicker is the annoying phenomenon created when the screen
is erased between each frame of an animation sequence. This is
caused by the rapid combination of erasing and then drawing the
next frame, and it can be fixed only by eliminating the requirement
of erasing the screen.
<LI>Double buffering is a technique that helps eliminate flicker
when displaying an animation. It involves drawing the next frame
of animation to an offscreen buffer and then drawing the buffer
to the screen. This eliminates flicker because the screen never
has to be erased; the offscreen buffer is erased with each new
frame.
</OL>
<H2><A NAME="Day7"><B><FONT SIZE=5 COLOR=#FF0000>Day 7</FONT></B></A>
</H2>
<OL>
<LI>By the integers 0 to 7, where 0 represents 0 degrees (facing
up) and each other integer represents angles increasing by 45
degrees each time. For example, 3 represents 135 degrees and 4
represents 180 degrees.
<LI>The velocity multipliers are used to alter the velocity based
on the direction. For example, if the direction is 2, the angle
is 90 degrees and the sprite is facing right. Therefore, the X
velocity needs to be positive and the Y velocity needs to be zero.
<LI>In the <TT><FONT FACE="Courier">update</FONT></TT> method
of the <TT><FONT FACE="Courier">Tarantula</FONT></TT> class, the
decision of whether to create new spiderlings is determined in
a completely random fashion.
<LI>The same way that they determine whether to create spiderlings:
randomly via the <TT><FONT FACE="Courier">update</FONT></TT> method.
<LI>Two reasons. First, because you want to limit to 10 the number
of sprites that could be added to the list. Second, because you
want to eliminate collision detection and let the tarantulas walk
all over each other.
</OL>
<H2><A NAME="Day8"><B><FONT SIZE=5 COLOR=#FF0000>Day 8</FONT></B></A>
</H2>
<OL>
<LI>Absolute and relative.
<LI>Sorry, this was a little bit of a trick question. The answer
is whichever one works best! The point is that there are no hard
rules when determining the best user input approach in games.
<LI>In Java, it's not! This is a little inside joke for DOS (yikes!)
game programmers. Fortunately, Java frees you from the burdens
of low-level, processor-specific coding such as interrupt routines,
and it lets you deal with input at a more meaningful level.
</OL>
<H2><A NAME="Day9"><B><FONT SIZE=5 COLOR=#FF0000>Day 9</FONT></B></A>
</H2>
<OL>
<LI>An event is simply something that happens that you might want
to know about.
<LI>Call the <TT><FONT FACE="Courier">shiftDown</FONT></TT> method
on the <TT><FONT FACE="Courier">Event</FONT></TT> object that
is passed into the <TT><FONT FACE="Courier">mouseMove</FONT></TT>
event handler method.
<LI>By overriding the <TT><FONT FACE="Courier">mouseExit</FONT></TT>
event handler method.
<LI>The keyboard controls for the saucer are implemented by overriding
the <TT><FONT FACE="Courier">keyDown</FONT></TT> event handler
method and setting the velocity of the saucer according to which
arrow key was pressed. The mouse controls for the saucer are implemented
by overriding the <TT><FONT FACE="Courier">mouseDown</FONT></TT>
and <TT><FONT FACE="Courier">mouseDrag</FONT></TT> methods and
setting the position of the saucer based on the mouse position.
</OL>
<H2><A NAME="Day10"><B><FONT SIZE=5 COLOR=#FF0000>Day 10</FONT></B></A>
</H2>
<OL>
<LI>Frogger! That was just too easy.
<LI>With some lousy, meaningless points!
<LI>The <TT><FONT FACE="Courier">keyDown</FONT></TT> event handler
method is used to detect when the arrow keys are pressed. If an
arrow key is pressed, the gecko's velocity is set accordingly.
To only allow one movement per key press, the gecko's velocity
is reset to zero in the <TT><FONT FACE="Courier">update</FONT></TT>
method for <TT><FONT FACE="Courier">Gecko</FONT></TT>.
<LI>Pretty well. Geckos are extremely fast-much faster than your
Java-handicapped gecko.
<LI>By overriding the <TT><FONT FACE="Courier">action</FONT></TT>
method and checking to see whether the event target is of type
<TT><FONT FACE="Courier">Button</FONT></TT>. If so, the <TT><FONT FACE="Courier">arg</FONT></TT>
parameter is cast to a <TT><FONT FACE="Courier">String</FONT></TT>
and compared to the string <TT><FONT FACE="Courier">&quot;New
Game&quot;</FONT></TT>. If there is a match, the button was indeed
pressed, so the <TT><FONT FACE="Courier">newGame</FONT></TT> method
is called.
</OL>
<H2><A NAME="Day11"><B><FONT SIZE=5 COLOR=#FF0000>Day 11</FONT></B></A>
</H2>
<OL>
<LI>A sound wave is a series of traveling pressure changes in
the air.
<LI>A/D converters handle the task of converting analog audio
signals to digital audio signals that can be represented in a
computer.
<LI>8000 Hz.
<LI>The amount of time between when you play a sound in an applet
and when the user actually hears it.
</OL>
<H2><A NAME="Day12"><B><FONT SIZE=5 COLOR=#FF0000>Day 12</FONT></B></A>
</H2>
<OL>
<LI>Unfortunately, the answer is no. You'll have to wait for a
future release of Java to remedy this situation. However, all
is not lost, because on Day 11 you learned that many popular sound
editing tools enable you to convert sounds across a wide variety
of formats.
<LI>The <TT><FONT FACE="Courier">getCodeBase</FONT></TT> method
returns the base URL for the location of the current applet, whereas
the <TT><FONT FACE="Courier">getDocumentBase</FONT></TT> method
returns the base URL for location of the HTML document containing
the applet. Because resources such as sounds are typically stored
relative to the applet, it is both safer and smarter to use <TT><FONT FACE="Courier">getCodeBase</FONT></TT>
when you need a URL for loading a resource.
<LI>When you need to play a looped sound or when you plan on playing
a sound more than once.
<LI>By calling the <TT><FONT FACE="Courier">stop</FONT></TT> method
on the <TT><FONT FACE="Courier">AudioClip</FONT></TT> object used
to loop the sound.
</OL>
<H2><A NAME="Day13"><B><FONT SIZE=5 COLOR=#FF0000>Day 13</FONT></B></A>
</H2>
<OL>
<LI>Sky Harbor Airport in Phoenix, Arizona.
<LI>Because you need to be able to ignore the net sprite when
looking to see whether the player clicked a scorpion. It also
enables you to override the default response to collision detections.
<LI>Because they're nocturnal creatures.
<LI>Because it is necessary to stop the looped music when the
update thread is stopped. Otherwise, it would be possible for
the music to keep playing even though the rest of the applet was
stopped.
<LI>Because it must be accessible by other classes. More specifically,
the <TT><FONT FACE="Courier">lost</FONT></TT> member variable
is incremented in the <TT><FONT FACE="Courier">update</FONT></TT>
method of the <TT><FONT FACE="Courier">Scorpion</FONT></TT> class.
</OL>
<H2><A NAME="Day14"><B><FONT SIZE=5 COLOR=#FF0000>Day 14</FONT></B></A>
</H2>
<OL>
<LI>Single-stepping provides you with a means to see exactly how
your code is being executed, one line at a time.
<LI>A runtime error in your code.
<LI>When a derived class adds a variable with the same name as
a variable in one of its parent classes.
<LI>A list of the methods called en route to the currently executing
code.
</OL>
<H2><A NAME="Day15"><B><FONT SIZE=5 COLOR=#FF0000>Day 15</FONT></B></A>
</H2>
<OL>
<LI>Chasing, evading, and patterned.
<LI>Different behaviors are assigned probabilities for an object
and then selected based on these probabilities; each behavior
represents a particular type of action for an object, such as
fighting or fleeing.
<LI>Calculating a score based on the current state of the game.
<LI>Because hardware has only recently reached a point where it
can begin dealing with the heavy amount of processing required
of most AI systems.
</OL>
<H2><A NAME="Day16"><B><FONT SIZE=5 COLOR=#FF0000>Day 16</FONT></B></A>
</H2>
<OL>
<LI>The map is used to provide an efficient and logical way of
representing all the different winning scenarios in the game.
Without the map, you would have a significantly more difficult
time calculating scores and determining whether a player has won.
<LI>Because it logically makes sense to divide it into two separate
components. More important, however, is the fact that <TT><FONT FACE="Courier">Connect4State</FONT></TT>
must be able to be copied and used temporarily in a recursive
manner. This usage wouldn't be possible if everything was combined
in a single class.
<LI>Because the computer player's thinking algorithm is not implemented
in a thread. This results in the algorithm tying up the system
while it is running. Because the system is tied up, the screen
isn't updated and, therefore, the hand selector isn't drawn.
</OL>
<H2><A NAME="Day17"><B><FONT SIZE=5 COLOR=#FF0000>Day 17</FONT></B></A>
</H2>
<OL>
<LI>Turn-based and event-based.
<LI>From a strictly game design perspective, there is no difference.
The difference arises when you assess the bandwidth limitations
of each. Modem connections have much smaller bandwidths than physical
connections.
<LI>State synchronization, input synchronization, and hybrid.
</OL>
<H2><A NAME="Day18"><B><FONT SIZE=5 COLOR=#FF0000>Day 18</FONT></B></A>
</H2>
<OL>
<LI>A software abstraction that represents a communication channel
for a particular service such as FTP or HTTP.
<LI>Sockets are significant to network programming because they
allow you to focus on input and output operations, independent
of the intricacies and specifics involved with the network itself.
<LI>Stream sockets act like active connections, with data being
transferred immediately in real time; datagram sockets just broadcast
data over the Internet and hope that it eventually makes it to
the intended destination at some point in the future.
<LI>The generic socket class is important because it isolates
the common code involved in establishing general communications
between clients and a server. This code can be easily reused in
more specific client/server classes designed to support a particular
game.
</OL>
<H2><A NAME="Day19"><B><FONT SIZE=5 COLOR=#FF0000>Day 19</FONT></B></A>
</H2>
<OL>
<LI>A daemon thread is a thread that runs in the background and
performs some type of support function, such as managing client
communications in the NetConnect4 game.
<LI>The <TT><FONT FACE="Courier">Game</FONT></TT> class handles
the details of managing the game logic and the communication between
players from the server side.
<LI>The <TT><FONT FACE="Courier">Connect4ClientConnection</FONT></TT>
class handles establishing a client socket connection, along with
managing the communication between players from the client's perspective.
</OL>
<H2><A NAME="Day20"><B><FONT SIZE=5 COLOR=#FF0000>Day 20</FONT></B></A>
</H2>
<OL>
<LI>Maintainability, size, and speed.
<LI>Method inlining.
<LI>A profiler helps you isolate which code is being called the
most and how much time is being spent there, which tells you where
to direct your optimization efforts.
<LI>When your code is reliant on costly calculations that can
be replaced with a table of integer constants.
</OL>
<H2><A NAME="Day21"><B><FONT SIZE=5 COLOR=#FF0000>Day 21</FONT></B></A>
</H2>
<OL>
<LI>Graphics utilities and sound utilities.
<LI>The one that works for you! That's no joke, because a development
tool is only useful to the degree that it saves you time and energy.
Research the tools for yourself and decide which, if any, of them
might suit your needs.
<LI>Rest and relaxation! Come on, you've finished the book; go
have a little fun and unwind!
</OL>
<P>
<HR WIDTH="100%"></P>

<CENTER><P><A HREF="ch4rev.htm"><IMG SRC="pc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="index.htm"><IMG SRC="hb.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="#CONTENTS"><IMG SRC="cc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="appb.htm"><IMG 
SRC="nc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A></P></CENTER>

<P>
<HR WIDTH="100%"></P>

</BODY>
</HTML>
